From c411c717d5c9f4944b4419434e1b83979b4720cb Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Fri, 10 Nov 2017 10:44:21 +0100 Subject: [PATCH] extensions: protect another conversion against /0.0 --- extensions/gggl.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/extensions/gggl.c b/extensions/gggl.c index d101bef..cf83988 100644 --- a/extensions/gggl.c +++ b/extensions/gggl.c @@ -560,10 +560,16 @@ conv_rgbA16_rgbaF (const Babl *conversion,unsigned char *src, unsigned char *dst { float alpha = (((unsigned short *) src)[3]) / 65535.0; int c; + float recip_alpha; + + if (alpha == 0.0f) + recip_alpha = 10000.0; + else + recip_alpha = 1.0/alpha; for (c = 0; c < 3; c++) { - (*(float *) dst) = (*(unsigned short *) src / 65535.0) / alpha; + (*(float *) dst) = (*(unsigned short *) src / 65535.0) * recip_alpha; dst += 4; src += 2; } -- 2.30.2